package com.xiaotou.struts.action;

import java.util.ArrayList;
import java.util.List;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;

import com.opensymphony.xwork2.ActionSupport;
import com.xiaotou.db.pojo.WbUser;
import com.xiaotou.domain.Prey;
import com.xiaotou.service.PreyService;
import com.xiaotou.utils.AuthUtils;
import com.xiaotou.weibo.WeiboClientException;

public class PreysAction extends ActionSupport {

	private static final long serialVersionUID = -6885617094243972818L;

	private PreyService preyService;

	private List<Prey> preys = new ArrayList<Prey>();

	@Action(value = "/preys", results = { @Result(name = "success", location = "/WEB-INF/jsp/preys.jsp") })
	public String getRandomPreys() throws WeiboClientException {
		final WbUser loginUser = AuthUtils.getLoginUser();
		this.preys = this.preyService.getRandomPreys(loginUser);
		return SUCCESS;
	}

	public List<Prey> getPreys() {
		return preys;
	}

	public void setPreyService(PreyService preyService) {
		this.preyService = preyService;
	}
}
